#include "Octahedral.h"
#include "E_Transform3.h"
#define PI 3.1415926
int main() {
	HWND hwnd = initgraph(500, 500);
	setbkcolor(WHITE);
	cleardevice();
	setorigin(250, 250);
	setaspectratio(1, -1);
	setlinecolor(BLACK);
	setlinestyle(PS_SOLID, 2);
	Octahedral octa;
	octa.GetPoint(); octa.GetFacet();
	Octahedral oct[4];
	oct[0].GetPoint(); oct[0].GetFacet();
	oct[1].GetPoint(); oct[1].GetFacet();
	oct[2].GetPoint(); oct[2].GetFacet();
	oct[3].GetPoint(); oct[3].GetFacet();
	E_Transform3 Rotate[4],rotate;
	rotate.SetMatrix(octa.GetVertexArrayName(), 6);
	Rotate[0].SetMatrix(oct[0].GetVertexArrayName(), 6);Rotate[0].E_Scale(0.4, 0.4, 0.4); Rotate[0].E_Translate(-150, 150, 0);
	Rotate[1].SetMatrix(oct[1].GetVertexArrayName(), 6); Rotate[1].E_Scale(0.4, 0.4, 0.4); Rotate[1].E_Translate(150, 150, 0);
	Rotate[2].SetMatrix(oct[2].GetVertexArrayName(), 6); Rotate[2].E_Scale(0.4, 0.4, 0.4); Rotate[2].E_Translate(150, -150, 0);
	Rotate[3].SetMatrix(oct[3].GetVertexArrayName(), 6); Rotate[3].E_Scale(0.4, 0.4, 0.4); Rotate[3].E_Translate(-150, -150, 0);
	E_Point3 CenterP[4] = {
		{-150,150,0},{150,150,0},{150,-150,0},{-150,-150,0}
	};
	for (; 1;) {
		BeginBatchDraw();
		setlinecolor(LIGHTMAGENTA);
		octa.Draw();
		rotate.E_RotateX(PI / 180);
		rotate.E_RotateY(PI / 180);
		rotate.E_RotateZ(PI / 180);

		setlinecolor(RED);
		Rotate[0].E_RotatePXY(PI / 180, CenterP[0]);
		oct[0].Draw();
		setlinecolor(GREEN);
		Rotate[1].E_RotatePZ(PI / 180, CenterP[1]);
		oct[1].Draw();
		setlinecolor(LIGHTBLUE);
		Rotate[2].E_RotatePY(PI / 180, CenterP[2]);
		oct[2].Draw();
		setlinecolor(LIGHTCYAN);
		Rotate[3].E_RotatePX(PI / 180, CenterP[3]);
		oct[3].Draw();
		FlushBatchDraw();
		Sleep(100);
		EndBatchDraw();
		cleardevice();
		
	}
	
	_getwch();
	closegraph();
	return 0;
}